var showchart = new Class({
	
	data : [],
	
	paths : [],
	
	initialize : function () {
		
	},
	setChartPath : function (chartType, chartPath) {
		this.paths.push({
			type : chartType,
			path : chartPath
		});
	},
	addChartData : function(type, name, xmlData, width, height) {
		this.data.push({
			type : type,
			name : name,
			width : width,
			height : height,
			xmlData : xmlData
		});
	},
	getPathByType : function (type) {
		var path = '';
		this.paths.each(function (value) {
			if (value.type == type) {
				path = value.path;
				return;
			}
		});
		return path;
	},
	render : function (name, type) {
		var showChart = '';
		this.data.each(function (value) {
			if (name == value.name && type == value.type) {
				showChart = value;
				return;
			}
		});
		if (!$defined(showChart) || showChart.path == '') {
			return;
		}
		var path = this.getPathByType(showChart.type);
		var showDiv = 'show_' + type;
		var showDivWidth = $('theForm').getSize().x;
		var width = showDivWidth < 500 ? 500 : showDivWidth;
		var myChart = new FusionCharts(path , showChart.name, width, showChart.height);
		//myChart.addVariable('scaleMode', 'exactFit');
		myChart.setDataXML(showChart.xmlData);
		myChart.render(showDiv);
	},
	setActions : function (selector) {
		var self = this;
		$$('#' + selector).each(function (op, index) {
			op.addEvent('change', function (event) {
				self.render(this.value, this.name);
			});
		});
		
	}
});